﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Enterprise.Infrastructure;
using Enterprise.Model.Meeting;
using Enterprise.Service.Meeting;
using Enterprise.Control;
namespace Enterprise.UI.Web.Modules.Meeting
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnCommand();
                BindGrid1();
                BindGrid2();
            }
        }

        private void OnCommand()
        {
            CreateBT.AddButton("new.gif", "发布会议信息", "Edit.aspx", Utility.PopedomType.New, HeadMenu1);
        }

        private void BindGrid1()
        {
            MeetingService mService = new MeetingService();
            var meetinglist = mService.MeetingList().OrderByDescending(p => p.MCreateTime).ToList();
            GridView1.DataSource = meetinglist;
            GridView1.DataBind();
        }

        private void BindGrid2()
        {
            MeetingService mService = new MeetingService();
            var meetinglist = mService.MeetingList().Where(p=>p.MUserId==Utility.Get_UserId).OrderByDescending(p => p.MCreateTime).ToList();
            GridView2.DataSource = meetinglist;
            GridView2.DataBind();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            BindGrid1();
        }

        protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView2.PageIndex = e.NewPageIndex;
            BindGrid2();
        }

    }
}